﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Net;

namespace ExpenseIt
{
    /// <summary>
    /// Interaction logic for mainMenu.xaml
    /// </summary>
    public partial class mainMenu : Page
    {
        public mainMenu()
        {
            InitializeComponent();
        }
        private bool CheckConnection(String URL)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
                request.Timeout = 5000;
                request.Credentials = CredentialCache.DefaultNetworkCredentials;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK) return true;
                else return false;
            }
            catch
            {
                return false;
            }
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            /*bool checkInternet=CheckConnection("http://www.digiply.com:8020/MyAPIWebService.svc/getUser");  //release this code for online run
            if (checkInternet == false)
            {
                TxtBlock.Text = "Internet Not Available";
                //var amb = 1;
            }
            else
            {
                TxtBlock.Text = "";
                TxtBlock.Text = "Loading Please wait...";
            goToOnline();
            }*/
            goToOnline();
            }
        private void goToOnline()
        {
            onlineModePage OMPage = new onlineModePage();
            this.NavigationService.Navigate(OMPage);
        }

        
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            offlineModePage OFMPage = new offlineModePage();
            this.NavigationService.Navigate(OFMPage);
        }
    }
}
